package com.jiantong.work.impl.service;

import com.google.common.base.Throwables;
import com.jiantong.work.impl.dao.BeastsBreedStockMessageDao;
import com.jiantong.work.model.BeastsBreedStockMessage;
import com.jiantong.work.service.BeastsBreedStockMessageWriteService;
import io.terminus.boot.rpc.common.annotation.RpcProvider;
import io.terminus.common.model.Response;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 数据分析 - 存栏合计统计
 * Created by mz03 on 2017/4/17.
 */
@Slf4j
@Service
@RpcProvider
public class BeastsBreedStockMessageWriteServiceImpl implements BeastsBreedStockMessageWriteService{

    private final BeastsBreedStockMessageDao beastsBreedStockMessageDao;

    @Autowired
    public BeastsBreedStockMessageWriteServiceImpl(BeastsBreedStockMessageDao beastsBreedStockMessageDao){
        this.beastsBreedStockMessageDao = beastsBreedStockMessageDao;

    }

    /**
     * 添加一条
     *
     * @param beastsBreedStockMessage
     * @return long 创建后返回ID
     */
    @Override
    public Response<Long> create(BeastsBreedStockMessage beastsBreedStockMessage) {
        return null;
    }

    @Override
    public Response<Integer> createBeastsBreedStockMessages(List<BeastsBreedStockMessage> beastsBreedStockMessages) {
        try{
            return Response.ok(beastsBreedStockMessageDao.creates(beastsBreedStockMessages));
        }catch (Exception e){
            log.error("failed to create beastsBreedStockMessages", Throwables.getStackTraceAsString(e));
            return Response.fail("failed to create beastsBreedStockMessages");
        }
    }

    /**
     * 更新一条
     *
     * @param beastsBreedStockMessage
     * @return boolean 是否更新成功
     */
    @Override
    public Response<Boolean> update(BeastsBreedStockMessage beastsBreedStockMessage) {
        return null;
    }
}
